package com.dcy.znoa.controller.demo;

import com.dcy.znoa.common.annotation.AuthenticationAPI;
import com.dcy.znoa.common.bean.Result;
import com.dcy.znoa.common.controller.BaseController;
import com.dcy.znoa.common.exception.BusinessException;
import com.dcy.znoa.domain.Oper;
import com.dcy.znoa.service.software.OperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
public class OperDemoController extends BaseController{
    @Autowired
    OperService userService;

    @AuthenticationAPI
    @ResponseBody
    @RequestMapping("/user/{id}")
    public Result getUserById(@PathVariable("id") Long id) throws BusinessException{
        return success(userService.getById(id));
    }

    @ResponseBody
    @RequestMapping("/user/list")
    public Result getUserById(Oper user) throws BusinessException{
        return success(userService.selectUserList(user));
    }

    @ResponseBody
    @RequestMapping("user/insert")
    public Result registrer(Oper user) throws BusinessException{
        return success(userService.save(user));
    }
}
